<?php

namespace App\Http\Controllers\Admin;

use App\Models\Apiiuser;
use Illuminate\Http\Request;

class ApiiuserController extends BaseController
{
    /**
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        $data = Apiiuser::paginate($this->pagesize);
        return view('admin.apiiuser.index', compact('data'));
    }

    /**
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function create()
    {
        return view('admin.apiiuser.create');
    }

    /**
     * @param Request $request
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     * @throws \Illuminate\Validation\ValidationException
     */
    public function store(Request $request)
    {
        $data             = $this->validate($request, [
            'username' => 'required|unique:apiiusers,username',
            'password' => 'required|confirmed',
        ]);
        // 加密使用事件箭筒完成
        # $data['password'] = bcrypt($data['password']);
        Apiiuser::create($data);
        return redirect(route('admin.apiiuser.index'));
    }

    /**
     * Display the specified resource.
     *
     * @param \App\Models\Apiiuser $apiiuser
     * @return \Illuminate\Http\Response
     */
    public function show(Apiiuser $apiiuser)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param \App\Models\Apiiuser $apiiuser
     * @return \Illuminate\Http\Response
     */
    public function edit(Apiiuser $apiiuser)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param \Illuminate\Http\Request $request
     * @param \App\Models\Apiiuser $apiiuser
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Apiiuser $apiiuser)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param \App\Models\Apiiuser $apiiuser
     * @return \Illuminate\Http\Response
     */
    public function destroy(Apiiuser $apiiuser)
    {
        //
    }
}
